#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;

const int N = 505;
const int K = 25;
const int INF = 0x3f3f3f3f;

int n, m, k;
int right_edge[N][N];  // 水平边权
int down_edge[N][N];   // 垂直边权
int dp[N][N][K];       // dp[i][j][s]: 从任意点走到(i,j)用s步的最小代价

int main() {
    scanf("%d%d%d", &n, &m, &k);

    // 如果k是奇数，直接输出-1
    if (k & 1) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                printf("-1 ");
            }
            printf("\n");
        }
        return 0;
    }

    // 初始化DP数组
    memset(dp, 0x3f, sizeof(dp));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            dp[i][j][0] = 0;  // 0步到达自己的代价为0
        }
    }

    // 读取水平边权
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j < m; j++) {
            scanf("%d", &right_edge[i][j]);
        }
    }

    // 读取垂直边权
    for (int i = 1; i < n; i++) {
        for (int j = 1; j <= m; j++) {
            scanf("%d", &down_edge[i][j]);
        }
    }

    // 动态规划：计算走s步的最小代价
    int steps = k / 2;
    for (int s = 1; s <= steps; s++) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                // 从四个方向转移过来
                if (i > 1) {  // 从上边来
                    dp[i][j][s] = min(
                        dp[i][j][s], dp[i - 1][j][s - 1] + down_edge[i - 1][j]);
                }
                if (i < n) {  // 从下边来
                    dp[i][j][s] =
                        min(dp[i][j][s], dp[i + 1][j][s - 1] + down_edge[i][j]);
                }
                if (j > 1) {  // 从左边来
                    dp[i][j][s] = min(dp[i][j][s], dp[i][j - 1][s - 1] +
                                                       right_edge[i][j - 1]);
                }
                if (j < m) {  // 从右边来
                    dp[i][j][s] = min(dp[i][j][s],
                                      dp[i][j + 1][s - 1] + right_edge[i][j]);
                }
            }
        }
    }

    // 输出结果：每个点走k步回到自己的最小代价是走k/2步最小代价的2倍
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (dp[i][j][steps] == INF) {
                printf("-1 ");
            } else {
                printf("%d ", dp[i][j][steps] * 2);
            }
        }
        printf("\n");
    }

    return 0;
}